<!-- HTML header for doxygen 1.8.10-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>NATS C Client with Streaming support: Libuv Adapter</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="customdoxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;" >
   <div id="projectname">NATS C Client with Streaming support
   &#160;<span id="projectnumber">2.1.0</span>
   </div>
   <div id="projectbrief">The nats.io C Client, Supported by Synadia Communications Inc.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__libuv_functions.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Libuv Adapter</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga5d4b677cbe1cd132c37bc56dbfc6949e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#ga5d4b677cbe1cd132c37bc56dbfc6949e">natsLibuv_Init</a> (void)</td></tr>
<tr class="memdesc:ga5d4b677cbe1cd132c37bc56dbfc6949e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the adapter.  <a href="#ga5d4b677cbe1cd132c37bc56dbfc6949e">More...</a><br /></td></tr>
<tr class="separator:ga5d4b677cbe1cd132c37bc56dbfc6949e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1baf4a20b138dcf00807a8b830f4e02d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#ga1baf4a20b138dcf00807a8b830f4e02d">natsLibuv_SetThreadLocalLoop</a> (uv_loop_t *loop)</td></tr>
<tr class="memdesc:ga1baf4a20b138dcf00807a8b830f4e02d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Register the event loop with the thread running <code>uv_run()</code>.  <a href="#ga1baf4a20b138dcf00807a8b830f4e02d">More...</a><br /></td></tr>
<tr class="separator:ga1baf4a20b138dcf00807a8b830f4e02d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga86ac71cffe752effd7397740d80c3c42"><td class="memItemLeft" align="right" valign="top"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#ga86ac71cffe752effd7397740d80c3c42">natsLibuv_Attach</a> (void **userData, void *loop, <a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec">natsConnection</a> *nc, <a class="el" href="nats_8h.html#af798865ac824e5959987de0fe8d07383">natsSock</a> socket)</td></tr>
<tr class="memdesc:ga86ac71cffe752effd7397740d80c3c42"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach a connection to the given event loop.  <a href="#ga86ac71cffe752effd7397740d80c3c42">More...</a><br /></td></tr>
<tr class="separator:ga86ac71cffe752effd7397740d80c3c42"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga85c722b2d2699a954362b20528f0aaac"><td class="memItemLeft" align="right" valign="top"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#ga85c722b2d2699a954362b20528f0aaac">natsLibuv_Read</a> (void *userData, bool add)</td></tr>
<tr class="memdesc:ga85c722b2d2699a954362b20528f0aaac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start or stop polling on READ events.  <a href="#ga85c722b2d2699a954362b20528f0aaac">More...</a><br /></td></tr>
<tr class="separator:ga85c722b2d2699a954362b20528f0aaac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafaa633c9067f485f330b72644277b07d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#gafaa633c9067f485f330b72644277b07d">natsLibuv_Write</a> (void *userData, bool add)</td></tr>
<tr class="memdesc:gafaa633c9067f485f330b72644277b07d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start or stop polling on WRITE events.  <a href="#gafaa633c9067f485f330b72644277b07d">More...</a><br /></td></tr>
<tr class="separator:gafaa633c9067f485f330b72644277b07d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8df663525fb59b882a0f3bd563083dc7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__libuv_functions.html#ga8df663525fb59b882a0f3bd563083dc7">natsLibuv_Detach</a> (void *userData)</td></tr>
<tr class="memdesc:ga8df663525fb59b882a0f3bd563083dc7"><td class="mdescLeft">&#160;</td><td class="mdescRight">The connection is closed, it can be safely detached.  <a href="#ga8df663525fb59b882a0f3bd563083dc7">More...</a><br /></td></tr>
<tr class="separator:ga8df663525fb59b882a0f3bd563083dc7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Adapter to plug a <code>NATS</code> connection to a <code>libuv</code> event loop. </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga5d4b677cbe1cd132c37bc56dbfc6949e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void natsLibuv_Init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Needs to be called once so that the adapter can initialize some state. </p>

</div>
</div>
<a class="anchor" id="ga1baf4a20b138dcf00807a8b830f4e02d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void natsLibuv_SetThreadLocalLoop </td>
          <td>(</td>
          <td class="paramtype">uv_loop_t *&#160;</td>
          <td class="paramname"><em>loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Since <code>libuv</code> is not thread-safe, the adapter needs to know in which thread <code>uv_run()</code> will run for the given <code>loop</code>. It allows the adapter to schedule events so that they are executed in the event loop thread.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">loop</td><td>an event loop. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga86ac71cffe752effd7397740d80c3c42"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsLibuv_Attach </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>userData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>loop</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec">natsConnection</a> *&#160;</td>
          <td class="paramname"><em>nc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="nats_8h.html#af798865ac824e5959987de0fe8d07383">natsSock</a>&#160;</td>
          <td class="paramname"><em>socket</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This callback is invoked after <code>NATS</code> library has connected, or reconnected. For a reconnect event, <code>*userData</code> will not be <code>NULL</code>. This function will start polling on READ events for the given <code>socket</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">userData</td><td>the location where the adapter stores the user object passed to the other callbacks. </td></tr>
    <tr><td class="paramname">loop</td><td>the event loop as a generic pointer. Cast to appropriate type. </td></tr>
    <tr><td class="paramname">nc</td><td>the connection to attach to the event loop </td></tr>
    <tr><td class="paramname">socket</td><td>the socket to start polling on. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga85c722b2d2699a954362b20528f0aaac"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsLibuv_Read </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>userData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>add</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This callback is invoked to notify that the event library should start or stop polling for READ events.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">userData</td><td>the user object created in <a class="el" href="group__libuv_functions.html#ga86ac71cffe752effd7397740d80c3c42" title="Attach a connection to the given event loop. ">natsLibuv_Attach</a> </td></tr>
    <tr><td class="paramname">add</td><td><code>true</code> if the library needs to start polling, <code>false</code> otherwise. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gafaa633c9067f485f330b72644277b07d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsLibuv_Write </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>userData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>add</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This callback is invoked to notify that the event library should start or stop polling for WRITE events.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">userData</td><td>the user object created in <a class="el" href="group__libuv_functions.html#ga86ac71cffe752effd7397740d80c3c42" title="Attach a connection to the given event loop. ">natsLibuv_Attach</a> </td></tr>
    <tr><td class="paramname">add</td><td><code>true</code> if the library needs to start polling, <code>false</code> otherwise. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga8df663525fb59b882a0f3bd563083dc7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> natsLibuv_Detach </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>userData</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>When a connection is closed (not disconnected, pending a reconnect), this callback will be invoked. This is the opportunity to cleanup the state maintained by the adapter for this connection.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">userData</td><td>the user object created in <a class="el" href="group__libuv_functions.html#ga86ac71cffe752effd7397740d80c3c42" title="Attach a connection to the given event loop. ">natsLibuv_Attach</a> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">NATS.IO Supported By Synadia Communications Inc.
    <a href="http://www.nats.io">
    </a></li>
  </ul>
</div>
</body>
</html>
